package Spring.demo.controller;

import Spring.demo.component.UserComponent;
import Spring.demo.model.Student;
import Spring.demo.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

@Controller
public class StudentController {

//    //获取 Bean 对象=>属性注入
//    @Autowired
//    private StudentService studentService;
//    public  void hello()
//    {
//        studentService.hello();
//    }

    //获取 Bean 对象=>set注入

//    private StudentService studentService;
//    @Autowired
//    public void setStudentService(StudentService studentService) {
//        this.studentService = studentService;
//    }
//
//    public  void hello()
//    {
//
//        studentService.hello();
//    }



//    //构造⽅法注⼊
//
//    private  StudentService studentService;
//    private UserComponent userComponent;
//
//
//    @Autowired
//    public StudentController(StudentService studentService, UserComponent userComponent) {
//        this.studentService = studentService;
//        this.userComponent = userComponent;
//    }
//
//    public  void hello()
//    {
//
//        studentService.hello();
//    }


        
    @Resource(name = "s2")
    private Student student;
    public  void hello()
    {

        System.out.println(student.toString());
    }


}
